package com.artpri.service.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.artpri.model.Goods;
import com.artpri.model.vo.SimpleGoods;
import com.artpri.service.GoodsService;

/**
 * 商品 -service
 * @author ZhangSi
 */
public class GoodsServiceImpl extends BaseService implements GoodsService {

	@Override
	@Transactional(readOnly=true)
	public Goods get(int id) {
		return getGoodsDao().get(Goods.class, id);
	}

	@Override
	@Transactional(readOnly=true)
	public SimpleGoods getSimpleGoods(Integer goodsNum) {
		return getSimpleGoodsDao().get(goodsNum);
	}

	@Override
	@Transactional
	public List<SimpleGoods> getSimpleGoods(List<Integer> goodsNumList) {
		List<SimpleGoods>  list = null;
		if (goodsNumList != null && goodsNumList.size() != 0) {
			list = new ArrayList<>();
			for (Iterator<Integer> it = goodsNumList.iterator(); it.hasNext();) {
				SimpleGoods sg = getSimpleGoodsDao().get(it.next());
				list.add(sg);
			}
		}
		return list;
	}
}
